package ru.pb.game.network.engine.client.packets.receivable;

import ru.pb.game.network.engine.client.packets.FromClientToGameServerPacket;
import ru.pb.game.network.engine.client.packets.sendable.PROTOCOL_SHOP_ENTER_ACK;
import ru.pb.game.objects.model.players.Player;
import ru.pb.game.objects.model.players.enums.SLOT_STATE;

public class PROTOCOL_SHOP_ENTER_REQ extends FromClientToGameServerPacket
{
	private int _v;

	public PROTOCOL_SHOP_ENTER_REQ()
	{
		_log.info(" === SEND " + getClass().getSimpleName() + " ===");
	}

	@Override
	public void readImpl()
	{
		readH();
		_v = readD();
	}

	@Override
	public void runImpl()
	{
		Player p = getPlayer();
		if(p != null)
		{
			if(p.getRoom() != null)
				p.getRoom().changeSlotState(p.getSlot(), SLOT_STATE.SLOT_STATE_SHOP);
			p.sendPacket(new PROTOCOL_SHOP_ENTER_ACK(_v));
		}
	}
}